package com.chuyu.jzwboa.activity.log;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.chuyu.jzwboa.R;
import com.chuyu.jzwboa.adapter.log.LogAdapter;
import com.chuyu.jzwboa.base.MVPBaseActivity;
import com.chuyu.jzwboa.presenter.log.LogPresenter;
import com.chuyu.jzwboa.utils.sys.StatusBarUtils;
import com.chuyu.jzwboa.view.log.ILogView;
import com.jcodecraeer.xrecyclerview.ProgressStyle;
import com.jcodecraeer.xrecyclerview.XRecyclerView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 我的日志
 */
public class MyLogActivity extends MVPBaseActivity<ILogView, LogPresenter> implements ILogView, View.OnClickListener {

	@BindView(R.id.iv_cancel_log)
	ImageView ivCancelLog;
	@BindView(R.id.rl_personalmsg)
	RelativeLayout rlPersonalmsg;
	@BindView(R.id.log_recyclerview)
	XRecyclerView logRecyclerview;
	@BindView(R.id.iv_write_log)
	ImageView ivWriteLog;
	private LogPresenter logPresenter;
	private LogAdapter logAdapter;

	@NonNull
	@Override
	public LogPresenter createPresenter() {
		logPresenter = new LogPresenter();
		return logPresenter;
	}

	@Override
	protected int initContent() {
		return R.layout.activity_my_log;
	}

	@Override
	protected void initView() {
		ivCancelLog.setOnClickListener(this);
		ivWriteLog.setOnClickListener(this);
		LinearLayoutManager layoutManager = new LinearLayoutManager(this);
		layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
		logRecyclerview.setLayoutManager(layoutManager);
		logRecyclerview.setRefreshProgressStyle(ProgressStyle.BallSpinFadeLoader);
	}

	@Override
	protected void initData() {
		/**
		 * 动态设置状态栏高度
		 */
		int statusHeight = StatusBarUtils.getStatusHeight(this);
		rlPersonalmsg.setPadding(0, statusHeight, 0, 0);
		List<Integer> list = new ArrayList<>();
		list.add(1);
		list.add(1);
		list.add(1);
		logAdapter = new LogAdapter(getApplicationContext(), list);
		logRecyclerview.setAdapter(logAdapter);
	}

	@Override
	public void showPorgressBar() {

	}

	@Override
	public void closePorfressBar() {

	}

	@Override
	public void LoginSuccess() {

	}

	@Override
	public void LoginFailed() {

	}

	@Override
	public void LoadExpetion() {

	}

	@Override
	public void onClick(View view) {
		switch (view.getId()) {
			case R.id.iv_cancel_log:
				finish();
				break;
			//跳转写日志界面
			case R.id.iv_write_log:
				startActivity(new Intent(getApplicationContext(),WriteLogActivity.class));
				break;
		}
	}

}
